<template>
  <div class="task-assign-page">
    <el-card class="assign-card">
      <template #header>
        <div class="card-header">
          <span>任务分配</span>
          <el-button type="primary" @click="handleAssign" v-if="hasPerm('task:assign:assign')">分配任务</el-button>
        </div>
      </template>
      
      <el-table :data="assignList" style="width: 100%">
        <el-table-column prop="taskCode" label="任务编号" width="120" />
        <el-table-column prop="taskName" label="任务名称" width="200" />
        <el-table-column prop="assignee" label="分配人" width="100" />
        <el-table-column prop="assignDate" label="分配日期" width="120" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="scope">
            <el-tag type="primary">已分配</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150">
          <template #default="scope">
            <el-button size="small" @click="handleView(scope.row)" v-if="hasPerm('task:assign:view')">查看</el-button>
            <el-button size="small" type="primary" @click="handleReassign(scope.row)" v-if="hasPerm('task:assign:reassign')">重新分配</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { hasPerm } from '@/utils/permission'
import { ElMessage } from 'element-plus'

const assignList = ref([])

const handleAssign = () => {
  ElMessage.info('分配任务功能')
}

const handleView = (row) => {
  ElMessage.info(`查看分配：${row.taskCode}`)
}

const handleReassign = (row) => {
  ElMessage.info(`重新分配：${row.taskCode}`)
}

onMounted(() => {
  // 模拟数据
  assignList.value = [
    {
      taskCode: 'TASK001',
      taskName: '需求分析',
      assignee: '张三',
      assignDate: '2025-07-20',
      status: 'assigned'
    },
    {
      taskCode: 'TASK002',
      taskName: '系统设计',
      assignee: '李四',
      assignDate: '2025-07-22',
      status: 'assigned'
    }
  ]
})
</script>

<style scoped>
.task-assign-page {
  padding: 20px;
}

.assign-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style> 